package com.example.paymentdemo.contorller;

import com.example.paymentdemo.config.WxPayConfig;
import com.example.paymentdemo.entity.Product;
import com.example.paymentdemo.service.ProductService;
import com.example.paymentdemo.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * @Author 上号
 * @Date 2022/5/11 20:34
 * @Version 1.0
 */
//开放前端的跨域访问
@CrossOrigin
@RestController
@RequestMapping("/api/product/")
public class ProductController {
    @PostMapping("test")
    public R tset(){
        return R
                .ok()
                .data("message", "hello")
                .data("now", LocalDateTime.now());

    }
    @Resource
    private ProductService productService;
    @GetMapping("list")
    public R test(){
        List<Product> list = productService.list();
        return R.ok().data("productList",list);
    }

    /**
     * 测试 微信商户号连接配置
     * @return
     */
    @Autowired
    private WxPayConfig wxPayConfig;
    @GetMapping("getMchId")
    public R testwxpay(){

        return R.ok().data("mchid",wxPayConfig.getMchId());
    }
}
